package cn.itsource.controller;

import cn.itsource.common.AjaxResult;
import cn.itsource.common.PageResult;
import cn.itsource.domain.TEmployee;
import cn.itsource.query.EmployeeQuery;
import cn.itsource.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Effect:
 * date: 2022/1/13 19:19
 *
 * @author wangyu
 * @since JDK 1.8
 */
@RestController
@RequestMapping("/emp")
public class EmployeeController {
    @Autowired
    private IEmployeeService employeeService;

    @GetMapping("/findall")
    public List<TEmployee> findAll(){
        return employeeService.findAll();
    }

    @GetMapping("/findemplist")
    public List<TEmployee> findEmpList(){
        return employeeService.findEmpList();
    }

    @PostMapping("/findbyquery")
    public PageResult<TEmployee> findByQuery(@RequestBody EmployeeQuery employeeQuery){

        return employeeService.findByQuery(employeeQuery);
    }
    @GetMapping("/del")
    public AjaxResult del(Long id){
        return employeeService.del(id);
    }

    @PostMapping("/saveandupt")
    public AjaxResult saveAndUpt(@RequestBody TEmployee employee){
        return employeeService.saveAndUpt(employee);
    }


    @GetMapping("/findempbyid")
    public TEmployee findEmpById(Long id){
       return employeeService.findEmpById(id);
    }
}
